package com.sy.simpleegg.serialport.backscan

import com.sy.simpleegg.ext.logFile
import org.cnbleu.serialport.SerialPort

class BackscanController(
    portName: String,
    baudrate: SerialPort.BAUDRATE,
    stopb: SerialPort.STOPB,
    datab: SerialPort.DATAB,
    parity: SerialPort.PARITY,
    private val listener: BackscanListener,
    speed: Long = 10L
) : BackscanBaseController(portName, baudrate, stopb, datab, parity, speed){

    init {
        logFile("打开反扫器，串口号=$portName 波特率=$baudrate 停止位=$stopb 数据位=$datab 校验位=$parity")
    }

    override fun onReceive(receivedData: String) {
        listener.onReceive(receivedData)
    }

    interface BackscanListener{
        fun onReceive(data: String)
    }
}